------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\ecascardi\Desktop\STATA\Orphans and Schooling\Replication/orphans-log.log
  log type:  text
 opened on:  22 Jul 2015, 10:03:52

. 
. clear

. set mem 300m

. set matsize 300

. set more off

. 
. use "$REPDIR/data_replication_24jan06_v1", clear

. 
. *****************************
. ** MAKING APPENDIX TABLES ***
. *****************************
. 
. *** TABLE A3: ATTRITION AND CHILD CHARACTERISTICS ***
.         gen age_in_98a=age_in_98
(30040 missing values generated)

.                 replace age_in_98a=0 if age_in_98==.
(30040 real changes made)

.         gen miss_age=(age_in_98==.)

.         gen fem_age=female*age_in_98a
(1870 missing values generated)

.         gen cow_age=cows*age_in_98a
(80942 missing values generated)

.         gen lat_age=latrine*age_in_98a
(80951 missing values generated)

.         gen cln_age=clean*age_in_98a
(80927 missing values generated)

.         gen waz_age=waz*age_in_98a
(80932 missing values generated)

. 
.         capture drop n  

.         sort pupil yr  

.         bys pupil: gen n = _n  

.         bys pupil: gen N=_N

. 
.         gen totpar2 = totpar  
(27379 missing values generated)

. 
.         for num 1/5: gen nX=1 if n == X & totpar==. 

->  gen n1=1 if n == 1 & totpar==.
(127664 missing values generated)

->  gen n2=1 if n == 2 & totpar==.
(128805 missing values generated)

->  gen n3=1 if n == 3 & totpar==.
(127941 missing values generated)

->  gen n4=1 if n == 4 & totpar==.
(125698 missing values generated)

->  gen n5=1 if n == 5 & totpar==.
(125158 missing values generated)

.         for num 1/5: bys pupil: egen BnX=mean(nX) 

->  bys pupil: egen Bn1=mean(n1)
(115822 missing values generated)

->  bys pupil: egen Bn2=mean(n2)
(114330 missing values generated)

->  bys pupil: egen Bn3=mean(n3)
(110770 missing values generated)

->  bys pupil: egen Bn4=mean(n4)
(99364 missing values generated)

->  bys pupil: egen Bn5=mean(n5)
(95674 missing values generated)

. 
.         gen Attrit = 1 if Bn5==1 | (Bn4==1 & Bn5==1) | (Bn3==1 & Bn4==1 & Bn5==1) | (Bn2==1 & Bn3==1 & Bn4==1 & Bn5==1
> ) 
(95674 missing values generated)

.         replace Attrit = 0 if Attrit == .  
(95674 real changes made)

. 
.         gen Changer1=Changer
(30111 missing values generated)

.         replace Changer1=0 if DKorp==1
(28241 real changes made)

. 
.         gen OneYear=1 if n==1 & totpar~=.
(108200 missing values generated)

.         bys pupil: egen A1=mean(OneYear)
(16707 missing values generated)

.         replace OneYear=1 if A1==. & n[_n-1]==1 & totpar~=.
(1063 real changes made)

.         bys pupil: egen A2=mean(OneYear)
(11471 missing values generated)

.         replace OneYear=1 if A2==. & n[_n-2]==1 & totpar~=.
(789 real changes made)

.         bys pupil: egen A3=mean(OneYear)
(7582 missing values generated)

.         replace OneYear=1 if A3==. & n[_n-3]==1 & totpar~=.
(857 real changes made)

.         bys pupil: egen A4=mean(OneYear)
(3310 missing values generated)

.         replace OneYear=1 if A4==. & n[_n-4]==1 & totpar~=.
(288 real changes made)

.         replace OneYear=0 if OneYear==.
(105203 real changes made)

.         drop A1 A2 A3 A4

. 
.         * TABLE A3, COLUMN 1 *
.         dprobit DKorp female age_in_98a miss_age fem_age DivBud tw1 tw2 if OneYear==1 & Always~=1, cl(sch98)

Iteration 0:   log pseudolikelihood = -13503.532
Iteration 1:   log pseudolikelihood = -13006.126
Iteration 2:   log pseudolikelihood = -13004.876
Iteration 3:   log pseudolikelihood = -13004.876

Probit regression, reporting marginal effects           Number of obs =  24111
                                                        Wald chi2(7)  = 306.10
                                                        Prob > chi2   = 0.0000
Log pseudolikelihood = -13004.876                       Pseudo R2     = 0.0369

                                 (Std. Err. adjusted for 75 clusters in sch98)
------------------------------------------------------------------------------
         |               Robust
   DKorp |      dF/dx   Std. Err.      z    P>|z|     x-bar  [    95% C.I.   ]
---------+--------------------------------------------------------------------
  female*|   .0295648   .0120826     2.44   0.015   .486417   .005883  .053246
age_~98a |   .0157357   .0021147     7.44   0.000    9.3938   .011591   .01988
miss_age*|   .3985794   .0328911    12.44   0.000   .211314   .334114  .463045
 fem_age |   .0002448   .0010961     0.22   0.823   4.50521  -.001903  .002393
  DivBud*|   .0731829   .0182851     4.11   0.000   .383186   .037345  .109021
     tw1*|   .0479199   .0166467     2.90   0.004   .330762   .015293  .080547
     tw2*|   .1185741   .0259026     4.83   0.000   .028825   .067806  .169342
---------+--------------------------------------------------------------------
  obs. P |   .2479366
 pred. P |   .2401496  (at x-bar)
------------------------------------------------------------------------------
(*) dF/dx is for discrete change of dummy variable from 0 to 1
    z and P>|z| correspond to the test of the underlying coefficient being 0

.         * TABLE A3, COLUMN 2 *
.         dprobit DKorp female age_in_98a fem_age DivBud waz malaria latrine cows goats poultry shoes uniform clean cow_
> age lat_age cln_age waz_age tw1 tw2 if OneYear==1 & Always~=1, cl(sch98)

Iteration 0:   log pseudolikelihood = -4898.7166
Iteration 1:   log pseudolikelihood = -4764.7651
Iteration 2:   log pseudolikelihood = -4764.2399
Iteration 3:   log pseudolikelihood = -4764.2398

Probit regression, reporting marginal effects           Number of obs =   9789
                                                        Wald chi2(19) = 330.71
                                                        Prob > chi2   = 0.0000
Log pseudolikelihood = -4764.2398                       Pseudo R2     = 0.0275

                                 (Std. Err. adjusted for 75 clusters in sch98)
------------------------------------------------------------------------------
         |               Robust
   DKorp |      dF/dx   Std. Err.      z    P>|z|     x-bar  [    95% C.I.   ]
---------+--------------------------------------------------------------------
  female*|   .0337122   .0628027     0.54   0.590   .490653  -.089379  .156803
age_~98a |   .0198876    .007072     2.82   0.005   12.9406   .006027  .033749
 fem_age |  -.0012937   .0048102    -0.27   0.788   6.27797  -.010722  .008134
  DivBud*|   .0652686   .0184766     3.65   0.000   .339871   .029055  .101482
     waz |  -.0735295   .0246259    -3.02   0.003  -1.42703  -.121795 -.025264
 malaria*|   .0144653   .0087512     1.65   0.099   .392277  -.002687  .031617
 latrine*|  -.0631549   .0536116    -1.24   0.216   .819389  -.168232  .041922
    cows*|  -.1068696   .0572495    -1.86   0.062   .480948  -.219077  .005337
   goats*|   -.017674   .0080889    -2.19   0.029   .403514  -.033528  -.00182
 poultry*|  -.0370742   .0156587    -2.45   0.014    .92512  -.067765 -.006384
   shoes*|   .0329301    .011925     2.85   0.004   .150271   .009558  .056303
 uniform*|  -.0257551   .0142422    -1.86   0.063   .858821  -.053669  .002159
   clean*|   -.029649   .0540646    -0.56   0.578   .621412  -.135614  .076316
 cow_age |   .0068026   .0044861     1.53   0.127   6.23455   -.00199  .015595
 lat_age |   .0045623    .003692     1.23   0.218    10.639  -.002674  .011798
 cln_age |   .0023783   .0039156     0.61   0.542   8.13842  -.005296  .010053
 waz_age |   .0067371   .0018531     3.71   0.000    -18.52   .003105  .010369
     tw1*|    .024363   .0171692     1.43   0.151   .347942  -.009288  .058014
     tw2*|    .314248   .1699353     2.07   0.038   .000817  -.018819  .647315
---------+--------------------------------------------------------------------
  obs. P |   .2000204
 pred. P |   .1935642  (at x-bar)
------------------------------------------------------------------------------
(*) dF/dx is for discrete change of dummy variable from 0 to 1
    z and P>|z| correspond to the test of the underlying coefficient being 0

.         * TABLE A3, COLUMN 3 *
.         dprobit Attrit female age_in_98a miss_age fem_age DivBud Changer1 DKorp tw1 tw2 if OneYear==1 & Always~=1, cl(
> sch98)

Iteration 0:   log pseudolikelihood = -14241.496
Iteration 1:   log pseudolikelihood = -13882.415
Iteration 2:   log pseudolikelihood = -13882.086
Iteration 3:   log pseudolikelihood = -13882.086

Probit regression, reporting marginal effects           Number of obs =  24111
                                                        Wald chi2(9)  = 450.98
                                                        Prob > chi2   = 0.0000
Log pseudolikelihood = -13882.086                       Pseudo R2     = 0.0252

                                 (Std. Err. adjusted for 75 clusters in sch98)
------------------------------------------------------------------------------
         |               Robust
  Attrit |      dF/dx   Std. Err.      z    P>|z|     x-bar  [    95% C.I.   ]
---------+--------------------------------------------------------------------
  female*|   .0184279   .0125252     1.47   0.141   .486417  -.006121  .042977
age_~98a |  -.0062728   .0014576    -4.34   0.000    9.3938   -.00913 -.003416
miss_age*|  -.0575138   .0211344    -2.63   0.009   .211314  -.098936 -.016091
 fem_age |  -.0009882   .0012046    -0.82   0.412   4.50521  -.003349  .001373
  DivBud*|   .0003579   .0129795     0.03   0.978   .383186  -.025081  .025797
Changer1*|  -.0591543   .0120178    -4.69   0.000   .061175  -.082709   -.0356
   DKorp*|   .1676339   .0092916    19.24   0.000   .247937   .149423  .185845
     tw1*|  -.0041232   .0125674    -0.33   0.743   .330762  -.028755  .020508
     tw2*|   .0239149   .0181826     1.34   0.181   .028825  -.011722  .059552
---------+--------------------------------------------------------------------
  obs. P |   .2775911
 pred. P |   .2731156  (at x-bar)
------------------------------------------------------------------------------
(*) dF/dx is for discrete change of dummy variable from 0 to 1
    z and P>|z| correspond to the test of the underlying coefficient being 0

.         * TABLE A3, COLUMN 4 *
.         dprobit Attrit female age_in_98a fem_age DivBud waz malaria latrine cows goats poultry shoes uniform clean cow
> _age lat_age cln_age waz_age Changer1 DKorp tw1 tw2 if OneYear==1 & Always~=1, cl(sch98)

Iteration 0:   log pseudolikelihood = -5932.6731
Iteration 1:   log pseudolikelihood = -5746.4121
Iteration 2:   log pseudolikelihood = -5746.0091
Iteration 3:   log pseudolikelihood = -5746.0091

Probit regression, reporting marginal effects           Number of obs =   9789
                                                        Wald chi2(21) = 323.05
                                                        Prob > chi2   = 0.0000
Log pseudolikelihood = -5746.0091                       Pseudo R2     = 0.0315

                                 (Std. Err. adjusted for 75 clusters in sch98)
------------------------------------------------------------------------------
         |               Robust
  Attrit |      dF/dx   Std. Err.      z    P>|z|     x-bar  [    95% C.I.   ]
---------+--------------------------------------------------------------------
  female*|  -.1960217   .0567016    -3.39   0.001   .490653  -.307155 -.084889
age_~98a |  -.0179995   .0079577    -2.27   0.023   12.9406  -.033596 -.002403
 fem_age |   .0149276   .0044126     3.40   0.001   6.27797   .006279  .023576
  DivBud*|  -.0067964   .0154013    -0.44   0.660   .339871  -.036982   .02339
     waz |   .0301926   .0278926     1.08   0.280  -1.42703  -.024476  .084861
 malaria*|  -.0083587    .008882    -0.94   0.347   .392277  -.025767   .00905
 latrine*|   .2126316   .0480037     3.52   0.000   .819389   .118546  .306717
    cows*|   .0068446   .0523268     0.13   0.896   .480948  -.095714  .109403
   goats*|  -.0146528   .0111816    -1.31   0.191   .403514  -.036568  .007263
 poultry*|  -.0057898   .0208804    -0.28   0.781    .92512  -.046715  .035135
   shoes*|   .0443546   .0205226     2.22   0.026   .150271   .004131  .084578
 uniform*|   .0459388   .0141076     3.17   0.002   .858821   .018288  .073589
   clean*|   .2748037   .0492617     5.06   0.000   .621412   .178253  .371355
 cow_age |  -.0019232   .0039044    -0.49   0.622   6.23455  -.009576  .005729
 lat_age |   -.016965   .0054039    -3.11   0.002    10.639  -.027556 -.006374
 cln_age |    -.01959   .0044348    -4.45   0.000   8.13842  -.028282 -.010898
 waz_age |  -.0034521   .0020661    -1.67   0.096    -18.52  -.007502  .000597
Changer1*|  -.0536188   .0165614    -3.12   0.002   .068342  -.086079 -.021159
   DKorp*|   .0816231   .0130318     6.43   0.000    .20002   .056081  .107165
     tw1*|   .0106405   .0134108     0.79   0.427   .347942  -.015644  .036925
     tw2*|  -.0810897   .1749586    -0.42   0.673   .000817  -.424002  .261823
---------+--------------------------------------------------------------------
  obs. P |   .2944121
 pred. P |   .2880121  (at x-bar)
------------------------------------------------------------------------------
(*) dF/dx is for discrete change of dummy variable from 0 to 1
    z and P>|z| correspond to the test of the underlying coefficient being 0

. 
. *** TABLE A1: SUMMARY STATISTICS *** 
.         keep if totpar ~= .  
(27379 observations deleted)

.         format %9.2f Changer Never totpar insch female age_in_98 waz malaria latrine cows goats poultry shoes uniform 
> clean DivBud per_any_dd per_mom_dd per_dad_dd per_bth_dd  

. 
. *** TABLE A1, PANEL A: FULL SAMPLE ***  
.         su female age_in_98 Changer N_mat_orphan N_pat_orphan if FullS==1 & Year1==1

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
      female |     18133    .4774169    .4995035          0          1
   age_in_98 |     14970    11.79145    2.527039          5         18
     Changer |     18133    .0813434    .2733693          0          1
N_mat_orphan |     18133           0           0          0          0
N_pat_orphan |     18133           0           0          0          0

.         su per_any_dd per_mom_dd per_dad_dd per_bth_dd totpar insch if FullS==1 & Year1==1

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
  per_any_dd |     18133    .1473579     .050484   .0055556   .4126984
  per_mom_dd |     18133    .0490949    .0222932   .0055556         .2
  per_dad_dd |     18133    .1190612    .0437864   .0027778       .328
  per_bth_dd |     18133    .0207982     .011651          0       .124
      totpar |     18133    .8453688    .2255305          0          1
-------------+--------------------------------------------------------
       insch |     18133    .9800915    .1396896          0          1

.         
.         preserve 

.         keep yr pupil_id FullS N_mat_orph N_pat_orph N_any_orphan

.         keep if FullS==1
(32080 observations deleted)

.         reshape wide N_mat N_pat N_any_orphan FullS, i(pupil_id) j(yr)
(note: j = 1998 1999 2000 2001 2002)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                    73070   ->   18133
Number of variables                   6   ->      21
j variable (5 values)                yr   ->   (dropped)
xij variables:
                           N_mat_orphan   ->   N_mat_orphan1998 N_mat_orphan1999 ... N_mat_orphan2002
                           N_pat_orphan   ->   N_pat_orphan1998 N_pat_orphan1999 ... N_pat_orphan2002
                           N_any_orphan   ->   N_any_orphan1998 N_any_orphan1999 ... N_any_orphan2002
                                  FullS   ->   FullS1998 FullS1999 ... FullS2002
-----------------------------------------------------------------------------

. 
.         gen becamemat=0

.         gen becamepat=0

.         gen becameorphan=0

.         egen evermatorphan=rowmax(N_mat*)

.         egen everpatorphan=rowmax(N_pat*)

.         egen everorphan=rowmax(N_any_orphan*)

.         replace becamemat=1 if evermat==1
(538 real changes made)

.         replace becamepat=1 if everpat==1
(1061 real changes made)

.         replace becameorphan=1 if everorphan==1
(1475 real changes made)

.         sum everpatorphan

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
everpatorp~n |     18133    .0585121    .2347157          0          1

.         sum  evermatorphan

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
evermatorp~n |     18133    .0296697     .169679          0          1

.         sum  everorphan

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
  everorphan |     18133    .0813434    .2733693          0          1

.         
.         restore

. 
. *** TABLE A1, PANEL B: RESTRICTED SAMPLE ***  
.         su female age_in_98 Changer N_mat_orphan N_pat_orphan if Year1==1 & RestS==1

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
      female |      7815    .4825336    .4997268          0          1
   age_in_98 |      7769    12.90835    1.999509          6         18
     Changer |      7815    .0853487    .2794178          0          1
N_mat_orphan |      7815           0           0          0          0
N_pat_orphan |      7815           0           0          0          0

.         su per_any_dd per_mom_dd per_dad_dd per_bth_dd totpar insch waz malaria shoes uniform clean latrine cows goats
>  poultry if RestS == 1 & Year1 == 1  

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
  per_any_dd |      7815    .1406733     .047154   .0055556   .3461539
  per_mom_dd |      7815    .0462344    .0203898   .0055556   .1538462
  per_dad_dd |      7815    .1139653    .0412511   .0027778   .3076923
  per_bth_dd |      7815    .0195265     .010204          0   .1153846
      totpar |      7815    .9162106    .1658294          0          1
-------------+--------------------------------------------------------
       insch |      7815    .9966731    .0575872          0          1
         waz |      7815   -1.443974    .8172871      -4.79       2.34
     malaria |      7815    .3863084    .4869338          0          1
       shoes |      7815    .1396033    .3465972          0          1
     uniform |      7815    .8623161      .34459          0          1
-------------+--------------------------------------------------------
       clean |      7815    .6162508    .4863291          0          1
     latrine |      7815    .8209853    .3833892          0          1
        cows |      7815    .4909789    .4999506          0          1
       goats |      7815    .4122841    .4922773          0          1
     poultry |      7815    .9302623    .2547207          0          1

. 
.         preserve 

.         keep yr pupil_id RestS N_mat_orph N_pat_orph N_any_orphan

.         keep if RestS==1
(74333 observations deleted)

.         reshape wide N_mat N_pat N_any_orphan RestS, i(pupil_id) j(yr)
(note: j = 1998 1999 2000 2001 2002)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                    30817   ->    7815
Number of variables                   6   ->      21
j variable (5 values)                yr   ->   (dropped)
xij variables:
                           N_mat_orphan   ->   N_mat_orphan1998 N_mat_orphan1999 ... N_mat_orphan2002
                           N_pat_orphan   ->   N_pat_orphan1998 N_pat_orphan1999 ... N_pat_orphan2002
                           N_any_orphan   ->   N_any_orphan1998 N_any_orphan1999 ... N_any_orphan2002
                                  RestS   ->   RestS1998 RestS1999 ... RestS2002
-----------------------------------------------------------------------------

. 
.         gen becamemat=0

.         gen becamepat=0

.         gen becameorphan=0

.         egen evermatorphan=rowmax(N_mat*)

.         egen everpatorphan=rowmax(N_pat*)

.         egen everorphan=rowmax(N_any_orphan*)

.         replace becamemat=1 if evermat==1
(245 real changes made)

.         replace becamepat=1 if everpat==1
(486 real changes made)

.         replace becameorphan=1 if everorphan==1
(667 real changes made)

.         sum everpatorphan

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
everpatorp~n |      7815    .0621881    .2415123          0          1

.         sum  evermatorphan

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
evermatorp~n |      7815      .03135    .1742729          0          1

.         sum  everorphan

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
  everorphan |      7815    .0853487    .2794178          0          1

.         
.         restore

. STOP
unrecognized command:  STOP
r(199);

end of do-file

r(199);

. exit, clear
